package edu.chl.grupp11.aegas.controller.imp;

import java.util.Observable;
import java.util.ResourceBundle;

import edu.chl.grupp11.aegas.controller.ILanguageController;
import edu.chl.grupp11.aegas.model.AbstractConfig;
import edu.chl.grupp11.aegas.model.ConfigFactory;
import edu.chl.grupp11.aegas.view.MainView;

public class LanguageController implements ILanguageController {
	private MainView mainView;
	private AbstractConfig config = ConfigFactory.getSharedConfig();

	public LanguageController(MainView m) {
		mainView = m;
	}

	@Override
	public void setResourceBundle(String language) {
		ResourceBundle bundle = ResourceBundle
				.getBundle("edu/chl/grupp11/aegas/recources/bundles/"
						+ language);
		config.setResourceBundle(bundle);
	}

	@Override
	public void update(Observable obs, Object arg1) {
		String lang = mainView.getLanguage();
		setResourceBundle(lang);
	}

}
